home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / AmigaTalk / general / AmigaTalk.st next >
Encoding:
Text File  |  2004-01-31  |  7.2 KB  |  257 lines

  1. "--------------------------------------------------------------------"
  2. " AmigaTalk Class is now a Singleton class.                          "
  3. ""
  4. " HISTORY "
  5. "    03-Nov-2003 - Reinstated the amigatalk pseuod-variable.         "
  6. "    31-Oct-2003 - Added two methods to Set/Clear searching of the   "
  7. "                  internal memory lists for free slots.  The Clear  "
  8. "                  method will speed up code execution for large     "
  9. "                  instantiations, such as the Intuition Class.      "
  10. "    03-Oct-2003 - Added two new methods to add & remove User        "
  11. "                  Script menu items for the main AmigaTalk command  "
  12. "                  window (only!)                                    "
  13. "    03-Feb-2003 - Added a new instance variable for controlling the "
  14. "                  trace filing ability of AmigaTalk & three methods "
  15. "                  for using it (traceState, tracingOn & tracingOff)."
  16. ""
  17. " NOTES "
  18. "     ALL singleton classes MUST contain the following:              "
  19. ""
  20. "     the methods:  isSingleton AND privateSetup     AND             "
  21. "                   uniqueInstance Class instance variable.          "
  22. "--------------------------------------------------------------------"
  23.  
  24. Class AmigaTalk :Dictionary
  25. ! uniqueInstance atMsg wTitle globalDict traceControl !
  26. [
  27.    isSingleton
  28.      ^ true
  29. |
  30.    privateNew ! newinstance !
  31.      newinstance <- super new.
  32.  
  33.      ^ newinstance
  34. |
  35.    new
  36.      ^ (self privateSetup)
  37. |
  38.    privateSetup
  39.      (uniqueInstance isNil)
  40.        ifTrue: [uniqueInstance <- self privateNew.
  41.                 globalDict     <- Dictionary new.
  42.                 traceControl   <- false. " Turn off tracing paradigm by default "
  43.                ].
  44.  
  45.      ^ self
  46. |
  47.    getByteCodeArrayFrom: aClass for: aMethodString
  48.       ^ <primitive 159 aClass aMethodString>
  49. |
  50.    traceState
  51.       " Returns true if tracing ability is enabled, false if not. "
  52.       ^ (traceControl ~= false)
  53. |
  54.    tracingOn
  55.       " WARNING:  This method only enables tracing output, 
  56.       * it does NOT open the tracing file.  Only the Trace
  57.       * menu Item will do so.
  58.       "
  59.       traceControl <- true.
  60.       tracingon
  61. |
  62.    tracingOff
  63.       " WARNING:  This method only disables tracing output, 
  64.       * it does NOT close the tracing file.  Only the Trace
  65.       * menu Item will do so.
  66.       "
  67.       traceControl <- false.
  68.       tracingoff
  69. |
  70.    turnOffSearch
  71.       <primitive 186 12 0>
  72. |
  73.    turnOnSearch
  74.       <primitive 186 12 1>
  75. |
  76.    searchState
  77.       ^ <primitive 186 11>
  78. |
  79.    printString
  80.       ^ <primitive 152 (self class)>   "Over-ride parent method"
  81. |   
  82.    clearScreen
  83.       <primitive 162>  "For Curses & Plot3 only."
  84. |
  85.    globalDictionary
  86.       ^ globalDict
  87. |
  88.    addGlobal: newGlobal key: newKey
  89.       ^ (super at: newKey put: newGlobal)
  90. |
  91.    date
  92.       ^ <primitive 160 >
  93. |
  94.    debug: n
  95.       ^ <primitive 8 2 n>
  96. |
  97.    display
  98.       ^ <primitive 8 1 1>
  99. |
  100.    displayAssign
  101.       ^ <primitive 8 1 2>
  102. |
  103.    doPrimitive: primNumber withArguments: argArray
  104.       ^ <primitive 30 primNumber argArray>
  105. |
  106.    noDisplay
  107.       ^ <primitive 8 1 0>
  108. |
  109.    sh: command
  110.       ^ <primitive 125 command >
  111. |
  112.    time: aBlock      ! start !
  113.       start <- <primitive 161>.   "This is NOT very accurate!"
  114.       aBlock value.
  115.       ^ <primitive 161> - start
  116. |
  117.    getProcessAddress: procName
  118.       ^ <primitive 250 0 0 procName>
  119. |
  120.    getTaskAddress: taskName
  121.       ^ <primitive 250 0 1 taskName>
  122. |
  123.    getScreenAddress: screenName
  124.       ^ <primitive 250 0 2 screenName>
  125. |
  126.    getWindowAddress: windowName
  127.       ^ <primitive 250 0 3 windowName>
  128. |
  129.    getStringAddress: aString
  130.       ^ <primitive 250 3 1 aString>    "NOT Kosher smalltalk!"
  131. |
  132.    getIntegerAddress: anInteger
  133.       ^ <primitive 250 3 0 anInteger>  "NOT Kosher smalltalk!"
  134. |
  135.    getByteArrayAddress: aByteArray
  136.       ^ <primitive 250 3 2 aByteArray> "NOT Kosher smalltalk!"
  137. |
  138.    getTaskAddressList ! array !
  139.       ^ array <- <primitive 250 2 1>
  140. |
  141.    getProcessAddressList ! array!
  142.       ^ array <- <primitive 250 2 0>
  143. |
  144.    getScreenAddressList ! array !
  145.       ^ array <- <primitive 250 2 2> "return an Array of Screen addresses."
  146. |
  147.    getWindowAddressList ! array !
  148.       ^ array <- <primitive 250 2 3> "return an Array of Window addresses."
  149. |
  150.    showTaskProcessList
  151.       ^ <primitive 250 1 4>
  152. |
  153.    showScreenWindowList
  154.       ^ <primitive 250 1 5>
  155. |
  156.    displayProcessInfo: procAddress
  157.       ^ <primitive 250 1 0 procAddress>
  158. |
  159.    displayTaskInfo: taskAddress
  160.       ^ <primitive 250 1 1 taskAddress>
  161. |
  162.    displayScreenInfo: screenAddress
  163.       ^ <primitive 250 1 2 screenAddress>
  164. |
  165.    displayWindowInfo: windowAddress
  166.       ^ <primitive 250 1 3 windowAddress>
  167. |
  168.    setIOMessage: newMessage
  169.       atMsg <- newMessage.
  170. |
  171.    setIOTitle: newTitle
  172.       wTitle <- newTitle.
  173. |
  174.    getUserResponse: questionString ! window !
  175.       
  176.       window <- self activeWindow.
  177.  
  178.       ^ window yesNoReq: questionString title: wTitle
  179. |
  180.    informUser: informationString ! window !
  181.       
  182.       window <- self activeWindow.
  183.  
  184.       ^ window infoReq: informationString title: wTitle
  185. |
  186.    newIO: msgString title: title
  187.       self setIOMessage: msgString.
  188.       self setIOTitle: title.
  189. |
  190.    setIODirectory: newDirectory
  191.       atMsg <- newDirectory.
  192. |
  193.    setIOScreenName: newScreenName
  194.       atMsg <- newScreenName.
  195. |
  196.    getString
  197.       ^ <primitive 186 0 atMsg wTitle>  "Return a String from the User."
  198. |
  199.    getInteger
  200.       ^ <primitive 186 1 atMsg wTitle>  "Return an Integer from the User."
  201. |
  202.    getFileName
  203.       ^ <primitive 186 5 atMsg wTitle>  "Get a filename from ASL."
  204. |
  205.    getScreenModeID        "atMsg is the Screen title for this method"
  206.       ^ <primitive 186 6 atMsg wTitle>  "Get a ScreenModeID from ASL."
  207. |
  208.    displayFile: fileName
  209.       <primitive 186 2 fileName>
  210. |      
  211.    displayString: string
  212.       <primitive 186 3 string atMsg wTitle>
  213. |
  214.    displayInteger: integer
  215.       <primitive 186 4 integer atMsg wTitle>
  216. |
  217.    listClassDictionaryTo: fileName indent: numSpaces
  218.       ^ <primitive 137 0 0 fileName numSpaces>  
  219. |
  220.    listClassesOf: classObj to: fileName indent: numSpaces
  221.       ^ <primitive 137 0 1 classObj fileName numSpaces>  
  222. |
  223.    fileInPrimitiveFile: fileName
  224.       " Primitive files end with .p (NOT enforced) 
  225.       * & represent parsed Class source code 
  226.       "
  227.       <primitive 138 0 0 fileName>
  228. |
  229.    activeScreen
  230.       " Returns a Screen Object: "
  231.       ^ <primitive 186 7>
  232. |
  233.    activeWindow
  234.       " Returns a Window Object or nil: "
  235.       ^ <primitive 186 8>
  236. |
  237.    addUserScript: scriptMenuName toCall: scriptFileName
  238.       ^ <primitive 186 9 scriptMenuName scriptFileName>
  239. |
  240.    removeUserScript: scriptMenuName
  241.       <primitive 186 10 scriptMenuName>
  242. |
  243.    systemPrivate
  244.       <primitive 137 0 2 'AmigaTalk:Browser/GeneralClasses' 'AmigaTalk:General' 0>.
  245.       <primitive 137 0 3 'AmigaTalk:Browser/GeneralClassInstanceVars' 'AmigaTalk:General'>.
  246.  
  247.       <primitive 137 0 2 'AmigaTalk:Browser/IntuitionClasses' 'AmigaTalk:Intuition' 0>.
  248.       <primitive 137 0 3 'AmigaTalk:Browser/IntuitionClassInstanceVars' 'AmigaTalk:Intuition'>.
  249.  
  250.       <primitive 137 0 2 'AmigaTalk:Browser/SystemClasses' 'AmigaTalk:System' 0>.
  251.       <primitive 137 0 3 'AmigaTalk:Browser/SystemClassInstanceVars' 'AmigaTalk:System'>
  252. |
  253.    updateUserBrowserFiles
  254.       <primitive 137 0 2 'AmigaTalk:Browser/UserClasses' 'AmigaTalk:User' 0>.
  255.       <primitive 137 0 3 'AmigaTalk:Browser/UserClassInstanceVars' 'AmigaTalk:User'>
  256. ]
  257.